using UnityEngine;
using System.Collections;

public class ColorBoxHandler :  Clickable{

	public GameObject referer;
	
	public override void onClick(){
		if(referer.GetComponent<ColorPickerHandler>()!=null){
			Color newColor = this.renderer.material.color;
			
			GPObject prevObj = new GPObject(referer.transform.parent.gameObject);
			GPObject newObj = new GPObject(referer.transform.parent.gameObject);
			newObj.ObjColor = newColor;
			
			if(prevObj.Type == ObjectType.Filter && prevObj.ObjColor == Color.white){
				THistory.Instance.addAction(new TAddAction(newObj));	
			}else{
				THistory.Instance.addAction(new TChangeColorAction(prevObj,newObj));
			}
			
			referer.GetComponent<ColorPickerHandler>().colorObject(newColor);
		}
		
	}
	
}
